﻿
namespace Go
{
	public enum Player
	{
		none = 0,
		black = 1,
		white = 2
	}
	static class PlayerEx
	{
		public static Player other(this Player player)
		{
			return player == Player.white ? Player.black : Player.white;
		}
	}

	public struct Point
	{
		public int row;
		public int col;
		public Point(int r, int c) { row = r; col = c; }
		public static Point None = new Point() { row = -1, col = -1 };
		public Point[] neighbors()
		{
			return new Point[]
			{
				new Point(row - 1, col),
				new Point(row + 1, col),
				new Point(row, col - 1),
				new Point(row, col + 1),
			};
		}
		public Point[] sight()
		{
			return new Point[]
			{
				new Point(row - 1, col),
				new Point(row + 1, col),
				new Point(row, col - 1),
				new Point(row, col + 1),
			};
		}
		public static bool operator ==(Point lhs, Point rhs)
		{
			return lhs.row == rhs.row && lhs.col == rhs.col;
		}
		public static bool operator !=(Point lhs, Point rhs)
		{
			return lhs.row != rhs.row || lhs.col != rhs.col;
		}
		public override int GetHashCode()
		{
			return row * 20 + col;
		}
		public override bool Equals(object obj)
		{
			return base.Equals(obj);
		}
	}
}
